import time import cookielib import urllib import urllib2 import time while True: cookie=cookielib.CookieJar() opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie)) loging_data=urllib.urlencode([ ('email',"xxx@qq.com"), ('passwd',"xxx"), ('remember_me','week')]) headers = { 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0', 'Host' : 'free.hwss.pw', 'Accept' :'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language':'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3', 'Referer' : 'http://free.hwss.pw/user/login.php', 'Connection' : 'keep-alive', 'Upgrade-Insecure-Requests':'1', } req=urllib2.Request(url='http://free.hwss.pw/user/_login.php', data=loging_data.encode(encoding='utf-8'), headers=headers) try: result=opener.open(req) print 'tttttttttttt' except urllib2.HTTPError: print("connect failed") try: req=urllib2.Request(url='http://free.hwss.pw/user/_checkin.php', data=loging_data.encode(encoding='utf-8'), headers=headers) result2=opener.open(req) print "ck1" except Exception,e: print str(e) print "1 finished,plz wait" time.sleep(86401)
|